package cn.edu.buu.news.vo;

public class Result<T> {
    //编码
    private Integer code;
    //数据
    private T resultData;
    //错误信息
    private String errorMessage;
    //构造私有
    private Result (Integer code){
        this.code = code;
    }
    public Result(Integer code, String errorMessage){
        this.code = code;
        this.errorMessage = errorMessage;
    }
    private Result(Integer code, T resultData){
        this.code = code;
        this.resultData = resultData;
    }
    //公有静态方法获取Result对象
    //成功带数据，用于查
    public static <T> Result success(T data){
        return new Result(200,data);
    }
    //成功不带数据，用于增删改
    public static Result success(){
        return new Result(200);
    }
    //失败
    public static  Result fail(Integer code,String errorMessage){
        return new Result(code,errorMessage);
    }
    public T getResultData() {
        return resultData;
    }

    public String getErrorMessage() {
        return errorMessage;
    }

    public Integer getCode() {
        return code;
    }



}
